<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('添加合同')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-contract-edit" th:object="${contract}">
            <input name="id" th:field="*{id}" type="hidden">
            <input name="status" type="hidden" value="2">
            <input name="type" type="hidden" value="0">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">订单号：</label>
                <div class="col-sm-8">
                    <input name="insuranceNumber" th:field="*{insuranceNumber}" class="form-control" type="text" readonly required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">投保日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="insuredDate" th:value="${#dates.format(contract.insuredDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" disabled required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">生效日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="startDate" th:value="${#dates.format(contract.startDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" disabled required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">失效日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="endingDate" th:value="${#dates.format(contract.endingDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" disabled required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">业务员姓名：</label>
<!--                <div class="col-sm-8">-->
<!--                    <input name="userName" th:field="*{userName}" class="form-control" type="text" required>-->
<!--                </div>-->
                <div class="col-sm-8">
                    <select name="userName" th:with="type=${@dict.getUser()}"class="form-control m-b" onchange="getUser()" disabled >
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}" th:field="*{userName}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">业务员代码：</label>
                <div class="col-sm-8">
                    <input name="userStaffCode" th:field="*{userStaffCode}" class="form-control" type="text" readonly required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">投保人姓名：</label>
                <div class="col-sm-8">
                    <input name="applicantName" th:field="*{applicantName}" class="form-control" type="text" disabled>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">投保人证件类型：</label>
                <div class="col-sm-8">
                    <select name="applicantIdType" class="form-control m-b" th:with="type=${@dict.getType('id_type')}" disabled>
                        <option></option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{applicantIdType}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">投保人证件号：</label>
                <div class="col-sm-8">
                    <input name="applicantId" th:field="*{applicantId}" class="form-control" type="text" disabled>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">投保人国籍：</label>
                <div class="col-sm-8">
                    <select name="applicantNationality" class="form-control m-b" th:with="type=${@dict.getType('nationality')}" disabled>
                        <option></option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{applicantNationality}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">投保人现住址：</label>
                <div class="col-sm-8">
                    <input name="applicantSite" th:field="*{applicantSite}" class="form-control" type="text" disabled>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">被保人姓名：</label>
                <div class="col-sm-8">
                    <input name="recognizeeName" th:field="*{recognizeeName}" class="form-control" type="text" disabled>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">被保人证件类型：</label>
                <div class="col-sm-8">
                    <select name="recognizeeIdType" class="form-control m-b" th:with="type=${@dict.getType('id_type')}" disabled>
                        <option></option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{recognizeeIdType}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">被保人证件号：</label>
                <div class="col-sm-8">
                    <input name="recognizeeId" th:field="*{recognizeeId}" class="form-control" type="text" disabled>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">被保人国籍：</label>
                <div class="col-sm-8">
                    <select name="recognizeeNationality" class="form-control m-b" th:with="type=${@dict.getType('nationality')}" disabled>
                        <option></option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{recognizeeNationality}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">被保人现住址：</label>
                <div class="col-sm-8">
                    <input name="recognizeeSite" th:field="*{recognizeeSite}" class="form-control" type="text" disabled>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">险种名称：</label>
<!--                <div class="col-sm-8">-->
<!--                    <input name="insuranceName" th:field="*{insuranceName}" class="form-control" type="text">-->
<!--                </div>-->
                <div class="col-sm-8">
                    <select disabled name="insuranceName" th:with="type=${@dict.getinsuranceName()}"class="form-control m-b" onchange="getinsurance()" >
                        <option></option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}" th:field="*{insuranceName}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">险种编码：</label>
                <div class="col-sm-8">
                    <input disabled name="insuranceCode" th:field="*{insuranceCode}" class="form-control" type="text" readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">保费：</label>
                <div class="col-sm-8">
                    <input disabled name="insuranceExpense" th:field="*{insuranceExpense}" class="form-control" type="text" readonly>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">保额：</label>
                <div class="col-sm-8">
                    <input disabled name="insuranceQuota" th:field="*{insuranceQuota}" class="form-control" type="text" readonly>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-offset-5 col-sm-10">
                    <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>复核完毕</button>&nbsp;
                    <button type="button" class="btn btn-sm btn-danger" onclick="revise()" ><i class="fa fa-reply-all"></i>问题件录入</button>
                </div>
            </div>
<!--            <div style="text-align: center">-->
<!--                    <button><strong>复核完毕</strong></button>-->
<!--                    <button><strong>问题件录入</strong></button>-->
<!--            </div>-->
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">合同状态：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="status" th:field="*{status}" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "insurance/review";
        $("#form-contract-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(ctx + "insurance/contract" + "/edit", $('#form-contract-edit').serialize());
            }
        }
        function revise() {
            $("input[name='type']").val("1");
            if ($.validate.form()) {
                $.operate.save(ctx + "insurance/contract" + "/edit", $('#form-contract-edit').serialize());
            }
        }

        $("input[name='insuredDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true,
        });

        $("input[name='startDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='endingDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        function getUser()
        {
            $.ajax({
                type: "POST",
                url: ctx +"system/user/getStaffCode",
                data: {"userName":$("select[name='userName']").val()},//参数列表
                success: function(result){
                    //请求正确之后的操作
                    $("input[name='userStaffCode']").val(result)
                },
                error: function(result){
                    //请求失败之后的操作
                }
            });

        }
        function getinsurance()
        {
            $.ajax({
                type: "POST",
                url: ctx +"insurance/insurance/selectInsuranceByInsuranceName",
                data: {"insuranceName":$("select[name='insuranceName']").val()},//参数列表
                success: function(result){
                    //请求正确之后的操作
                    $("input[name='insuranceCode']").val(result.code)
                    $("input[name='insuranceExpense']").val(result.expense)
                    $("input[name='insuranceQuota']").val(result.quota)
                },
                error: function(result){
                    //请求失败之后的操作
                }
            });

        }
    </script>
</body>
</html>